<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function muti(num){
            return new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    resolve(num*num)
                },1000)
            })
        }
        var arr = [2,3,4];
        /* 
        forEach 是一个同步的循环
        of 支持异步循环qq
        */
        (async()=>{
            /* arr.forEach(async(item)=>{
                var res = await muti(item)
                console.log(res)
            }) */
            for(let value of arr){
                let res = await muti(value)
                console.log(res)
            }
        })()

        /* var res = await getHotHttp()
    var arr = await getNewHttp()
    var str = await getHostHttp()
    var music = this.data.music
    Object.assign(music,{hots:{
      title:'热门歌曲',
      imgurl:'/images/hot.png',
      playlists:res.data.playlists.slice(0,3)
    }},{news:{
      title:'最新音乐',
      imgurl:'/images/new.png',
      playlists:arr.data.albums.slice(0,3)
    }},{hosts:{
      title:'主播电台',
      imgurl:'/images/host.png',
      playlists:str.data.result.slice(0,3)
    }})
    music.news.playlists.forEach(item=>{
      item.coverImgUrl = item.blurPicUrl
    })
    music.hosts.playlists.forEach(item=>{
      item.coverImgUrl = item.picUrl
    }) */
    // console.log(music)
    /* this.setData({
      music
    }) */

    </script>
</body>
</html>